package com.example.controller;

import com.example.entity.MessageNotice;
import com.example.entity.authority.SystemUser;
import com.example.ext.entity.ExtMessageNotice;
import com.example.service.MessageNoticeService;
import com.example.service.SysUserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * Created by simon on 2017/10/12.
 */
@RestController
@RequestMapping("api/notice")
public class NoticeController {

    @Autowired
    private MessageNoticeService messageNoticeService;

    @Autowired
    private SysUserService sysUserService;

    @ApiOperation(value = "查询通知列表的信息",notes = "获取通知列表信息")
    @RequestMapping(value="/queryList",method = RequestMethod.POST)
    Map<String,Object> queryList(@RequestBody ExtMessageNotice extMessageNotice) {

        return messageNoticeService.queryList(extMessageNotice);
    }

    @ApiOperation(value = "查询自己发的通知列表的信息",notes = "查询自己发的通知列表的信息")
    @RequestMapping(value="/querySendList",method = RequestMethod.POST)
    Map<String,Object> querySendList(@RequestBody ExtMessageNotice extMessageNotice) {

        return messageNoticeService.querySendList(extMessageNotice);
    }

    @ApiOperation(value = "修改为已读",notes = "修改为已读")
    //@ApiImplicitParam(name = "map",value = "map")
    @RequestMapping(value="/updateReadState",method = RequestMethod.POST)
    Map<String,Object> updateReadState(@RequestBody Map<String, Object> map) {

        return messageNoticeService.updateReadState(map);
    }

    /**
	 * 机构批量发通知
	 * 
	 * @param param
	 *            title: 通知标题
	 *            content: 通知内容
	 *            partyType: 通知单位类型
	 *            sendUserId: 发送人编号
	 * @return
	 */
    @ApiOperation(value = "机构批量发通知",notes = "机构批量发通知")
    //@ApiImplicitParam(name = "MessageNotice",value = "MessageNotice")
    @RequestMapping(value="/batchMsg",method = RequestMethod.POST)
    Map<String,Object> batchMsg(@RequestBody Map<String, Object> param) {
        return messageNoticeService.batchMsg(param);
    }

    @ApiOperation(value = "添加通知",notes = "添加通知")
    //@ApiImplicitParam(name = "MessageNotice",value = "MessageNotice")
    @RequestMapping(value="/add",method = RequestMethod.POST)
    Map<String,Object> add(@RequestBody MessageNotice messageNotice) {
        return messageNoticeService.add(messageNotice);
    }

    @RequestMapping(value="/findById/{id}",method = RequestMethod.POST)
    Map<String,Object> findById(@PathVariable(value = "id") String id) {

        return messageNoticeService.findById(id);
    }

}
